Skip to content

Conversation

@booxter
Copy link

@booxter booxter commented Feb 1, 2026

When running the test suite on darwin as part of nixpkgs package build,
we often hit the following error:

       >         mx.synchronize()
       >         t()
       >         gc.collect()
       >         expected = get_mem()
       >         for _ in range(100):
       >             t()
       >         used = get_mem()
       > >       self.assertEqual(expected, used)
       > E       AssertionError: 273678336 != 273694720

You can find an example of the full failure log here:
https://hydra.nixos.org/build/320731525

The difference between actual and expected is 16k (one page size on
aarch64-darwin).

The test seems brittle as it depends on peak memory, not real memory
at the moment of measurement, so anything during the run of the process
that could push the allocator to allocate another page can break the
test.

This patch switches the test case to measure real memory using psutil on
all platforms.

Signed-off-by: Ihar Hrachyshka ihar.hrachyshka@gmail.com

Proposed changes

Please include a description of the problem or feature this PR is addressing. If there is a corresponding issue, include the issue #.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

@booxter booxter force-pushed the fix-leak-test-failure-darwin branch from 9a4da58 to d0ce761 Compare February 1, 2026 23:31
When running the test suite on darwin as part of nixpkgs package build,
we often hit the following error:

```
       >         mx.synchronize()
       >         t()
       >         gc.collect()
       >         expected = get_mem()
       >         for _ in range(100):
       >             t()
       >         used = get_mem()
       > >       self.assertEqual(expected, used)
       > E       AssertionError: 273678336 != 273694720
```

You can find an example of the full failure log here:
https://hydra.nixos.org/build/320731525

The difference between actual and expected is 16k (one page size on
aarch64-darwin).

The test seems brittle as it depends on *peak* memory, not real memory
at the moment of measurement, so anything during the run of the process
that could push the allocator to allocate another page can break the
test.

This patch switches the test case to measure real memory using psutil on
all platforms.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
@booxter booxter force-pushed the fix-leak-test-failure-darwin branch from d0ce761 to 5413e30 Compare February 2, 2026 02:32
Copy link
Member

@awni awni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@booxter booxter marked this pull request as draft February 2, 2026 15:44
@booxter
Copy link
Author

booxter commented Feb 2, 2026

Looks like I broke something that was not present before I rebased to master. Will fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants